const db = uniCloud.database()
module.exports = {
	_before: function () { // 通用预处理器
		this.params = JSON.parse(this.getHttpInfo().body)
		this.ip = (this.getHttpInfo().headers)
		// this.params = this.getParams()
	},
	async get(){
		// return this.params
		let { ip } = this.params
		let res = await db.collection("user").get()
		let result = {
			code:200,
			msg:"查询成功",
			data:res.data
		}
		return result
	},
	async get1(){
		let result = {
			code:200,
			msg:"查询成功",
			data:this.ip
		}
		return result
	},
	async get_lianjie(){
		// return this.params
		let res = await db.collection("lianjie_data").get()
		let result = {
			code:200,
			msg:"查询成功",
			data:res.data
		}
		return result
	},
	async update(){
		let { id } = this.params
		let res = await db.collection("user").doc(id).update(this.params)
		return res
		let result = {
			code:200,
			msg:"更新成功",
			data:res.data
		}
		return result
	},
	async add_lianjie(){
		let { id } = this.params
		let res = await db.collection("lianjie_data").add(this.params)
		return res
		let result = {
			code:200,
			msg:"更新成功",
			data:res.data
		}
		return result
	},
	async update_lianjie(){
		let { id } = this.params
		let res = await db.collection("lianjie_data").doc(id).update(this.params)
		return res
		let result = {
			code:200,
			msg:"更新成功",
			data:res.data
		}
		return result
	},
}
